<template>
  <div>
    <el-table v-loading="loading" :data="dataSource" @row-click="handleRowClick" border :height="autoHeight">
      <el-table-column prop="historyType" label="操作" align="center" width="100px">
        <template slot="header" slot-scope="scope">
          <div>{{ scope.column.label }}</div>
          <el-input v-model="filterModel[scope.column.property]" :placeholder="scope.column.label + '过滤'" clearable @change="filterChange(scope.column.property)"></el-input>
        </template>
      </el-table-column>
      <el-table-column prop="sourceActivity" label="源节点" align="center" width="150px">
        <template slot="header" slot-scope="scope">
          <div>{{ scope.column.label }}</div>
          <el-input v-model="filterModel[scope.column.property]" :placeholder="scope.column.label + '过滤'" clearable @change="filterChange(scope.column.property)"></el-input>
        </template>
      </el-table-column>
      <el-table-column prop="targetActivity" label="目标节点" align="center" width="150px">
        <template slot="header" slot-scope="scope">
          <div>{{ scope.column.label }}</div>
          <el-input v-model="filterModel[scope.column.property]" :placeholder="scope.column.label + '过滤'" clearable @change="filterChange(scope.column.property)"></el-input>
        </template>
      </el-table-column>
      <el-table-column prop="activityLabels" label="影响业务" align="center" show-overflow-tooltip>
        <template slot="header" slot-scope="scope">
          <div>{{ scope.column.label }}</div>
          <el-input v-model="filterModel[scope.column.property]" :placeholder="scope.column.label + '过滤'" clearable @change="filterChange(scope.column.property)"></el-input>
        </template>
      </el-table-column>
      <el-table-column prop="createByName" label="操作人" align="center" width="150px"></el-table-column>
      <el-table-column prop="createAt" label="操作日期" align="center" width="150px"></el-table-column>
    </el-table>
    <div class="lab-table-page">
      <div style="display: inline-flex">
        <el-pagination
            :disabled="loading"
            :current-page="pageInfo.page"
            :page-sizes="[5, 10, 15, 20, 50, 100]"
            :page-size="pageInfo.pageSize"
            layout="total, sizes, jumper"
            :total="pageInfo.total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        />
        <el-button-group style="padding: 2px 5px">
          <el-button icon="el-icon-refresh" title="刷新" :disabled="loading" @click="loadSource([])" />
        </el-button-group>
      </div>
    </div>
  </div>
</template>

<script>
import IdeaTable from "@/mixins/IdeaTable";

export default {
  name: "ProcessHistory",
  mixins: [IdeaTable],
  inject: {
    /**
     * 流程方法注入
     */
    $labProcess: {
      from: '$labProcess',
      default: function () {
        return { info: {} }
      }
    },
  },
  data () {
    return {
      activityStates: [
        { value: 'runing', label: '进行中' },  { value: 'ready', label: '未开始' },
        { value: 'finish', label: '已完成' },  { value: 'cancel', label: '已退回' },
      ]
    }
  },
  created() {
    this.queryUrl = '/process/queryHistory'
    this.rowKey = 'historyId'
    const { processDefId, mainValue } = this.$labProcess.info
    this.addFilter({ field: 'processDefId', op: '=', value: processDefId || '0' })
    this.addFilter({ field: 'mainValue', op: '=', value: mainValue || '0' })
    this.pageInfo.sorts.push({ field: 'createAt', asc: false })
    this.loadSource()
  },
  computed: {
    autoHeight() {
      return `calc(100vh - 120px)`
    }
  }
}
</script>

<style scoped>

</style>
